#include "dri_systick.h"
static uint32_t fs_us=0;
static uint32_t fs_ms=0;
void  dri_systick_init(uint8_t systick)
{
	SysTick->CTRL &= ~0x05;
	fs_us=systick/8;
	fs_ms=fs_us*1000;
	
}
void dri_systick_ms(uint32_t ms)
{
	uint32_t SysTick_time=0;
	uint32_t temp=0;
	while(!SysTick_time)
	{
		if(ms>798)
		{
			SysTick->LOAD = fs_ms*798;
			ms=ms-798;
		}
		else
		{	
			SysTick->LOAD = fs_ms*ms;
			SysTick_time=1;
		}
		
		SysTick->CTRL |=0x01;
		do
		{
			temp=SysTick->CTRL;
		}
		while(!(temp&(0x01<<16)));
		SysTick->CTRL &= ~0x01;
	}
}
void dri_systick_us(uint32_t us)
{
	uint32_t temp=0;
	SysTick->LOAD = fs_us*us;
	SysTick->CTRL |=0x01;
	do	
	{
		temp=SysTick->CTRL;
	}
	while (!(temp&(0x01<<16)));
	SysTick->CTRL &= ~0x01;
}





